package com.objecteffects.template.model;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Rusty Wright
 */
public enum PostsType {
    POSTS,
    DRAFTS,
    QUEUE;

    private final String lcName;

    private static final Map<String, PostsType> STRING_TO_ENUM =
        new HashMap<>();

    PostsType() {
        this.lcName = this.name().toLowerCase();
    }

    static {
        for (final PostsType pt : values()) {
            PostsType.STRING_TO_ENUM.put(pt.toString(), pt);
        }
    }

    /*
     * Returns PostsType for string, or null if string is invalid.
     */
    public static PostsType fromString(final String name) {
        return PostsType.STRING_TO_ENUM.get(name);
    }

    @Override
    public String toString() {
        return this.lcName;
    }
}
